package com.cy.myblog.model;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

@Entity
@Table(name = "tclassify")
public class Tclassify implements Serializable{

	/**
	 * 文章分类
	 */
	private static final long serialVersionUID = -7017983739817912545L;
	private int id;
	private Set<Tarticle> articles;
	private String classifyname;
	private int sort;
	private int state;
	
	public Tclassify() {
		super();
	}

	public Tclassify(int id, Set<Tarticle> articles, String classifyname,
			int sort, int state) {
		super();
		this.id = id;
		this.articles = articles;
		this.classifyname = classifyname;
		this.sort = sort;
		this.state = state;
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getClassifyname() {
		return classifyname;
	}
	public void setClassifyname(String classifyname) {
		this.classifyname = classifyname;
	}

	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	@OneToMany(mappedBy = "tclassify")
	@LazyCollection(LazyCollectionOption.EXTRA)
	public Set<Tarticle> getArticles() {
		return articles;
	}

	public void setArticles(Set<Tarticle> articles) {
		this.articles = articles;
	}

	@Override
	public String toString() {
		return "Tclassify{" +
				"id=" + id +
				", articles=" + articles +
				", classifyname='" + classifyname + '\'' +
				", sort=" + sort +
				", state=" + state +
				'}';
	}
}
